<?php

	$appid = "wxc6b435d370c78efa";//用户的appid
	$redirect_uri = "wx.joygov.com/sheyang/wechat";//网页授权配置的域名
	$url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=$appid&redirect_uri=$redirect_uri&response_type=code&scope=snsapi_base&state=1&connect_redirect=1#wechat_redirect";
	$code = getOpenid($url);
	//echo 55;

	$type = $_GET['type'];
	if($type=='tousu'){
		header("location:http://wx.joygov.com/sheyang/complainForm.html?type=tousu&openid=$openid");
	}
	
		
	function getOpenid($url){

		$ch=curl_init();
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch,CURLOPT_HEADER,1);
    $result=curl_exec($ch);
    $code=curl_getinfo($ch,CURLINFO_HTTP_CODE);
    if($code!='404' && $result)
    {
        return $result;
    }
    curl_close($ch);
    }